package LeetCodeHot100TopInterview;

import java.util.LinkedList;
import java.util.List;

public class Q094_TreeInorderTraversal {
    //二叉树中序遍历
    public List<Integer> inorderTraversal(TreeNode root) {

        if (root == null){
            return new LinkedList<>();
        }
        List<Integer> ans = new LinkedList<>();
        process(root, ans);
        return ans;
    }

    public void process(TreeNode root, List<Integer> ans){
        if (root == null){
            return;
        }
        process(root.left, ans);
        ans.add(root.val);
        process(root.right, ans);
    }

}
